#ifndef QTBOX2DUNDONODE_H
#define QTBOX2DUNDONODE_H

#include <QtCore/QBuffer>
#include <QtCore/QStringList>
#include <QtCore/QVariant>

class QtBox2DScene;

class UndoNode
{
public:
	UndoNode(QtBox2DScene* inScene):mScene(inScene){}

	virtual void setUndoData(const QVariant& ){};
	virtual void setRedoData(const QVariant& ){};
	virtual void setItemNames(const QStringList& itemNames) { mItemNames = itemNames; };

	virtual void undo(){};
	virtual void redo(){};
protected:
	UndoNode(){};

	QStringList mItemNames;
	QtBox2DScene* mScene;
};

class UndoNode_Normal : public UndoNode
{
public:
	UndoNode_Normal(QtBox2DScene* inScene):UndoNode(inScene){}

	virtual const QVariant& getUndoData() const{ return mUndoValue; };
	virtual const QVariant& getRedoData() const{ return mRedoValue; };
	virtual void setUndoData(const QVariant& undoData){ mUndoValue = undoData; };
	virtual void setRedoData(const QVariant& redoData){ mRedoValue = redoData; };
	void setPropertyName(const QString& propertyName) { mItemProperty = propertyName; };
	const QString& getPropertyName() const { return mItemProperty; }
	
	void undo();
	void redo();
private:
	QString mItemProperty;
	QVariant mUndoValue;
	QVariant mRedoValue;
};

class UndoNode_Add : public UndoNode
{
public:
	UndoNode_Add(QtBox2DScene* inScene):UndoNode(inScene){}

	virtual void setItemNames(const QStringList& itemNames);

	void undo();
	void redo();
private:
	QBuffer mBuffer;
};

class UndoNode_Remove : public UndoNode
{
public:
	UndoNode_Remove(QtBox2DScene* inScene):UndoNode(inScene){}

	virtual void setItemNames(const QStringList& itemNames);

	void undo();
	void redo();
private:
	QBuffer mBuffer;
};

#endif